#ifndef MSGOUTLT_H
#define MSGOUTLT_H

class MsgOutlets
{
	public:
		MsgOutlets();
		~MsgOutlets();

		// ALL OUTLETS MUST FOLLOW THIS FORMAT: "<outlet name>" to be recognized
		// If outlets are nested, only the inner-most outlet will be recognized
		// (e.g. "<foo<bar>>" with <bar>==junk turns into "<foojunk>")
		//
		void add(char* outlet, uint8 id);		// length < 256

		int32 find(char* outlet);				// returns index or -1
		int32 find(char* outlet, int32 len);	// returns index or -1

		int32 getLen(int32 index);				// returns len or 0
		int32 getId(int32 index);				// return id or -1

		int32 getMaxLen();

	protected:
		int32	maxlen;
		int32	numOutlets;
		char**	outlets;
};

inline int32
MsgOutlets::getLen(int32 index)
{
	if (index >= 0 && index < numOutlets)
		return (int32)(uint8)outlets[index][0];
	else
		return 0;
}

inline int32
MsgOutlets::getId(int32 index)
{
	if (index >= 0 && index < numOutlets)
		return (uint8)outlets[index][1 + getLen(index) + 1];
	else
		return -1;
}

inline int32
MsgOutlets::getMaxLen()
{
	return maxlen;
}

#endif
